﻿using System;
using System.Collections;
using System.Windows.Forms;

namespace Moonlite.UI.Shell.Controls
{
    internal class MapExplorerNodeSorter : IComparer
    {
        public int Compare(object x, object y)
        {
            TreeNode tx = x as TreeNode;
            TreeNode ty = y as TreeNode;
            if (tx is NativeNode)
            {
                return -1;
            }
            else if (ty is NativeNode)
            {
                return 1;
            }

            if (tx.Text == "Children" && ty.Text != "Children")
            {
                return -1;
            }
            else if (ty.Text == "Children" && tx.Text != "Children")
            {
                return 1;
            }

            return string.Compare(tx.Text, ty.Text);
        }
    }
}
